<template>
	<view>
		<phone-directory :phones="phones" @paramClick="paramClick"></phone-directory>
		 <neil-modal :show="show" align="center" title="操作提示" :content="content"
		    @cancel="bindBtn('cancel')" @confirm="bindBtn('confirm')" @close="closeEvent">
		</neil-modal>
	</view>
</template>

<script>
	import phoneDirectory from '@/components/phone-directory/phone-directory.vue'
	import {apiContactsList} from '@/common/api.js'
	import neilModal from '@/components/neil-modal/neil-modal.vue'
	
	export default {
		name:"phones",
		components:{
			phoneDirectory,
			neilModal
		},
		data() {
			return {
				phones:{},
				show:false,
				content:'',
				phoneNumber:''
			}
		},
		onLoad(e){
			this.phones=JSON.parse(e.item)
		},
		methods : {
			paramClick (e) {
				if(e.phonenumber==""){
					uni.showToast({
						title:"没有电话号码",
						icon:'none'
					})
					return
				}
				this.show = true
				this.content = '将要拨打'+e.name+'的电话'
				this.phoneNumber = e.phonenumber
			},
			bindBtn (e){
				this.show = false
				if(e === 'confirm'){					
					uni.makePhoneCall({
						phoneNumber:this.phoneNumber
					})
				}			
			},
			closeEvent(){
				this.show = false
			}
		}
	}
</script>

<style>

</style>
